home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / PARAMS / SKEL1.PAS < prev    next >
Pascal/Delphi Source File  |  1994-03-24  |  2KB  |  88 lines

  1. program Skel1;
  2.                 {% an abridged version of Skel.pas without config %}
  3.  
  4. uses Dos, Params;
  5.  
  6. const
  7.     CopyNote = 'SKEL prototype 11-3-93';            {% change info %}
  8.  
  9. {ShowUsage: explain command-line parameters and options:}
  10. procedure ShowUsage; far;
  11. begin
  12.     writeln(CopyNote);
  13.     writeln('Usage:');
  14.                               {% explain parameters & options here %}
  15. end; {ShowUsage}
  16.  
  17. {*******************************************************}
  18.  
  19. {SetOpt: set the option named OptChr to the value given by OptStr:}
  20. { Uses GetBool for booleans; e.g., /a+ /b /c- : a,b true, c false }
  21. { Uses GetInt for integers; e.g., /a-16 /b23 : sets a= -16, b= 23 }
  22. { String values are direct; e.g., /fSomeName : sets f= 'SomeName' }
  23. procedure SetOpt; far;
  24. begin
  25.     case OptChr of
  26.                                             {% process option here %}
  27.                     {% use "if ParNo < 0" for initial-only options %}
  28.  
  29.         '?': begin
  30.             PAppDone;
  31.             ShowUsage;
  32.             Halt;
  33.         end;
  34.  
  35.         {none of the above:}
  36.         else RptError('Undefined option', Option, 'u');
  37.     end;
  38. end; {SetOpt}
  39.  
  40. {*******************************************************}
  41.  
  42. {DoFile: process the file (or name) FName:}
  43. procedure DoFile(FName: PathStr; Expdd: boolean); far;
  44.  
  45.     procedure IsFile;
  46.     begin
  47.         if not Expdd then begin
  48.             inc(FileNo);  inc(FPars);
  49.         end;
  50.     end;
  51.  
  52. begin {DoFile}
  53.                          {% process file here according to options %}
  54. {%    If Expdd = true, FName is expanded name of file found in Dir,
  55.     and global variables Path, Dir, and SRec may be used;
  56.     else, FName is just the ParStr, and not necessarily a filename.
  57.     Use "IsFile" to count FName as a file.                           %}
  58. end; {DoFile}
  59.  
  60. {AppDone: prepare to exit from the application:}
  61. procedure AppDone; far;
  62. begin
  63.         {% do anything needed for an orderly exit .. but don't halt %}
  64. end; {AppDone}
  65.  
  66. {*******************************************************}
  67.  
  68. begin    {main program}
  69.     {initialize procedure variables:}
  70.     PShowUsage:= ShowUsage;
  71.     PSetOpt:= SetOpt;
  72.     PDoFile:= DoFile;
  73.     PAppDone:= AppDone;
  74.  
  75.     if ParamCount = 0 then begin                         {% optional %}
  76.         ShowUsage;
  77.         halt;
  78.     end;
  79.             {% MayExpand:= false;    -- if desired to override default %}
  80.  
  81.     {ParNo := 1 to ParamCount used here:}
  82.     ScanPars;    {scan the command line}
  83.  
  84.                                 {% process here according to options %}
  85.  
  86.     AppDone;
  87. end.
  88.